<?php

namespace catchAdmin\pc\controller;

use catcher\base\CatchRequest as Request;
use catcher\CatchResponse;
use catcher\base\CatchController;
use catchAdmin\pc\model\ZhaoPin as ZhaoPinModel;
use think\Response;

class ZhaoPin extends CatchController
{

    protected $zhaoPinModel;


    /**
     *
     * @time 2025/09/17 16:33
     * @param ZhaoPinModel $zhaoPinModel
     * @return mixed
     */
    public function __construct(ZhaoPinModel $zhaoPinModel)
    {
        $this->zhaoPinModel = $zhaoPinModel;
    }


    /**
     *
     * @time 2025/09/17 16:33
     * @return Response
     */
    public function index(Request $request): Response
    {
        return CatchResponse::successPcList($this->zhaoPinModel->indexData($request->param()));
    }


    /**
     *
     * @time 2025/09/17 16:33
     * @param Request $request
     * @return Response
     */
    public function save(Request $request): Response
    {
        return CatchResponse::success($this->zhaoPinModel->storeBy($request->post()));
    }


    /**
     * 审核
     */
    public function audit(Request $request): Response
    {
        return CatchResponse::success($this->zhaoPinModel->audit($request->post()));
    }


    /**
     *
     * @time 2025/09/17 16:33
     * @param $id
     * @return Response
     */
    public function read($id): Response
    {
        return CatchResponse::success($this->zhaoPinModel->findBy($id));
    }


    /**
     *
     * @time 2025/09/17 16:33
     * @param $id
     * @param Request $request
     * @return Response
     */
    public function update($id, Request $request): Response
    {
        return CatchResponse::success($this->zhaoPinModel->updateBy($id, $request->post()));
    }


    /**
     *
     * @time 2025/09/17 16:33
     * @param $id
     * @return Response
     */
    public function delete($id): Response
    {
        return CatchResponse::success($this->zhaoPinModel->deleteBy($id));
    }
}
